<template>
  <div class="wrapper-content-nomargin">
    <!-- 参数区域 -->
    <portal-param-view ref="paramViewForm" :showSearchBtn="true" :pms="pms"></portal-param-view>
    <!-- 组件区域 -->
    <layout-view ref="optarea" :selfAdaption="true" :pageInfo="pageInfo"></layout-view>

  </div>
</template>
<script>
import request from "@/utils/request"
import {Loading} from 'element-ui'
import LayoutView from './LayoutView.vue'
import PortalParamView from './PortalParamView.vue'

export default {
  name: "portalMain",
  components: {
    LayoutView,
    PortalParamView
  },
  props: {},
  data() {
    return {
      token: null,
      reportId: null,
      pageInfo: {},
      pms: []
    }
  },

  methods: {
    getCfg() {
      request({
        url: "/bi/portal/share/get",
        method: "get",
        params: {token: this.token},
      }).then(resp => {
        this.pageInfo = JSON.parse(resp.rows);
        this.reportId = this.pageInfo.id;
        this.getReport();
      });
    },
    getReport() {
      let loadingInstance = Loading.service({
        fullscreen: false,
        target: document.querySelector('.wrapper-content-nomargin')
      });
      request({
        url: "/bi/portal/share/view",
        method: "GET",
        params: {token: this.token},
      }).then(resp => {
        //渲染组件
        this.$refs['optarea'].setCompData(resp.rows);
        this.pms = resp.rows.pms;
      });
    }
  },
  mounted() {
    this.token = this.$route.query.token;
    this.getCfg();
  },
  /**
   beforeRouteLeave: function(to, from, next) {
    this.$destroy();
    next();
  }
   */
}
</script>
